package han.chensing.latos.game.elements.character;

import com.badlogic.gdx.graphics.Color;

public class CharacterInstance {

    protected Character character;
    protected float health;
    protected float bufferHealth;
    protected float shownHealth;
    protected float maxHealth;
    protected boolean died;
    protected String functions;
    protected Color healthColor;
    protected Color hurtColor;
    protected Color bufferColor;

    public CharacterInstance(Character character) {
        shownHealth=health=maxHealth=character.maxHealth;
        healthColor=new Color(character.defaultHealthColor);
        hurtColor=new Color(character.defaultHurtColor);
        bufferColor=new Color(character.defaultBufferColor);
        hurtColor.a=0;
        died=false;
        this.character=character;
    }

    public void invokeTick(float delta){
        character.invokeTick(this, delta);
    }

    public void invokeMessage(String message){
        character.invokeMessage(this, message);
    }

    public boolean isDead(){
        return character.isDead(this);
    }

    public void increaseHealth(float value){
        float health = getHealth()+value;
        setHealth(Math.min(health, getMaxHealth()));
    }

    public void decreaseHealth(float value){
        float health = getHealth()-value;
        setHealth(Math.max(health,0));
    }

    public void resetHurtAlpha(){
        hurtColor.a=1f;
    }

    public float getHealth() {
        return health;
    }

    public void setHealth(float health) {
        this.health = health;
    }

    public float getMaxHealth() {
        return maxHealth;
    }

    public void setMaxHealth(float maxHealth) {
        this.maxHealth = maxHealth;
    }

    public boolean isDied() {
        return died;
    }

    public void setDied(boolean died) {
        this.died = died;
    }

    public String getFunctions() {
        return functions;
    }

    public void setFunctions(String functions) {
        this.functions = functions;
    }

    public Color getHealthColor() {
        return healthColor;
    }

    public void setHealthColor(Color healthColor) {
        this.healthColor = healthColor;
    }

    public Color getHurtColor() {
        return hurtColor;
    }

    public void setHurtColor(Color hurtColor) {
        this.hurtColor = hurtColor;
    }

    public Color getBufferColor() {
        return bufferColor;
    }

    public void setBufferColor(Color bufferColor) {
        this.bufferColor = bufferColor;
    }

    public float getBufferHealth() {
        return bufferHealth;
    }

    public void setBufferHealth(float bufferHealth) {
        this.bufferHealth = bufferHealth;
    }

    public float getShownHealth() {
        return shownHealth;
    }

    public void setShownHealth(float shownHealth) {
        this.shownHealth = shownHealth;
    }
}
